package Job.shopping.info;

public class Merchandise_News {
    private int number;
    private String name;
    private String category;
    private int quantity;
    private double price;

    public int getNumber() {
        return number;
    }
    public void setNumber(int number) {
        this.number = number;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getCategory() {
        return category;
    }
    public void setCategory(String category) {
        this.category = category;
    }
    public int getQuantity() {
        return quantity;
    }
    public void setQuantity(int quantity) {
        if (quantity > 0){
            this.quantity = quantity;
        }else {
            throw new RuntimeException("数量不能少于零!!!");
        }
    }
    public double getPrice() {
        return price;
    }
    public void setPrice(double price) {
        if (price > 0.00D){
            this.price = price;
        }else {
            throw new RuntimeException("叫个不能等于零或者是负的!!!");
        }
    }

    public Merchandise_News(int number, String name, String category, int quantity, double price) {
        this.setNumber(number);
        this.setName(name);
        this.setCategory(category);
        this.setQuantity(quantity);
        this.setPrice(price);
    }

    public Merchandise_News() {
    }

    public String DY(){
        String info = String.format("商品名称:%s,商品数量:%d,商品价格:%.2f,商品总价:%.2f",
                this.name,this.quantity,this.price,quantity*price);
        return info;
    }
}
